-
Couldn't load subscription status.
- Fork 73
fix: extend Node.js IncomingHttpHeaders in our Headers type #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes: cloudevents#340 Signed-off-by: Lance Ball <lball@redhat.com>
src/message/http/index.ts
Outdated
| */ | ||
| function getMode(headers: Headers): Mode { | ||
| const contentType = headers[CONSTANTS.HEADER_CONTENT_TYPE]; | ||
| const contentType = headers[CONSTANTS.HEADER_CONTENT_TYPE] as string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can add as const to the actual constants file instead of in every usage of this.
Ref: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions
in sdk-javascript/src/constants.ts
const CONSTANTS = Object.freeze({
CHARSET_DEFAULT: "utf-8",
...
} as const);
export default CONSTANTS;| }).to.throw; | ||
| }); | ||
|
|
||
| it("Can be created with Node's IncomingHttpHeaders", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
| // set headers | ||
| for (const key of Object.getOwnPropertyNames(message.headers)) { | ||
| post.set(key, message.headers[key]); | ||
| post.set(key, message.headers[key] as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we also have to submit an issue to superagent 😂
Signed-off-by: Lance Ball <lball@redhat.com>
Proposed Changes
IncomingHttpHeadersin ourHeaderstypeDescription
Changes the
Headerstype to make it more compatible with Node.js TypeScript projects.Signed-off-by: Lance Ball lball@redhat.com